package Expe12;

/**
 * @Author 28021
 * @Date 2022/11/30
 */

public class Person{
    String  name="";
    int age;
    public void setAge(int age) throws Exception {
        if (age >1 && age >100){
            this.age=age;
        }
        else{
            throw new Exception("年龄必须在1-100之间！");
        }
    }
    public void print(){
        System.out.println(this.name+" "+this.age+"岁");
    }
}
